package Juego;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;

public interface SerializablePropia {

	public Element serializar(Document doc);
	
	public static SerializablePropia hidratar(Node hidra) {
		Element eleConstruible=((Element) hidra);
		String clase=eleConstruible.getAttribute("Clase");
		try{
			Class[] c= new Class[]{Node.class};
			Method hidratar=Class.forName(clase).getMethod("hidratar",c);
			Object[] a=new Object[]{hidra};
			return  (SerializablePropia) hidratar.invoke(null,a);
		}catch(ClassNotFoundException e){}
		 catch(NoSuchMethodException e){}
		 catch(SecurityException e){}
		 catch(IllegalAccessException e){}
		 catch(IllegalArgumentException e){}
		 catch(InvocationTargetException e){}
		return null;
	}
	
}
